package com.soilflow.web.controller.know;

import com.soilflow.common.annotation.Log;
import com.soilflow.common.core.controller.BaseController;
import com.soilflow.common.core.domain.AjaxResult;
import com.soilflow.common.core.page.TableDataInfo;
import com.soilflow.common.domain.dto.KnowsInfoDto;
import com.soilflow.common.domain.vo.KnowsInfoVo;
import com.soilflow.common.enums.BusinessType;
import com.soilflow.know.service.KnowsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/info")
public class KnowsInfoController extends BaseController {

    @Autowired
    private KnowsInfoService knowsInfoService;

    /**
     * 查询大湖百事通列表
     */
   //    @PreAuthorize("@ss.hasPermi('land:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(KnowsInfoDto landInfo)
    {
        startPage();
        List<KnowsInfoVo> list = knowsInfoService.selectKnowsInfoList(landInfo);
        return getDataTable(list);
    }



    /**
     * 查询大湖百事通下拉列表
     */
    @GetMapping("/all")
    public AjaxResult listAll(KnowsInfoDto landInfo)
    {
        landInfo.setPageSize(null);
        List<KnowsInfoVo> list = knowsInfoService.selectKnowsInfoList(landInfo);
        return AjaxResult.success(list);
    }

    /**
     * 获取大湖百事通详细信息
     */
    //    @PreAuthorize("@ss.hasPermi('land:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(knowsInfoService.selectKnowsInfoById(id));
    }

    /**
     * 新增大湖百事通
     */
    //    @PreAuthorize("@ss.hasPermi('land:info:add')")
    @Log(title = "大湖百事通", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KnowsInfoDto landInfo)
    {
        return toAjax(knowsInfoService.insertKnowsInfo(landInfo));
    }

    /**
     * 修改大湖百事通
     */
    //    @PreAuthorize("@ss.hasPermi('land:info:edit')")
    @Log(title = "大湖百事通", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KnowsInfoDto landInfo)
    {
        return AjaxResult.success(knowsInfoService.updateKnowsInfo(landInfo));
    }

    /**
     * 删除大湖百事通
     */
    //    @PreAuthorize("@ss.hasPermi('land:info:remove')")
    @Log(title = "大湖百事通", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(knowsInfoService.removeByIds(ids));
    }

}
